package com.shoppingmall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shoppingmall.dao.GoodTypeDAO;
import com.shoppingmall.po.GoodTypePO;
import com.shoppingmall.service.GoodTypeService;

@Service
public class GoodTypeServiceImpl implements GoodTypeService {

	@Autowired
	private GoodTypeDAO goodTypeDao;
	/**
	 * 得到所有的目录
	 * @param i
	 * @return List<GoodTypePO>
	 */
	@Override
	public List<GoodTypePO> getType() {
		//首先先得到一级的目录
		List<GoodTypePO> oneGoodTypeList = goodTypeDao.getType(0);
		
		//遍历一级目录得到二级目录
		for (GoodTypePO type : oneGoodTypeList) {
			type.setListGoodTypePo(goodTypeDao.getType(type.getId()));
			
			//得到三级目录
			for (GoodTypePO typeTwo : type.getListGoodTypePo()) {
				typeTwo.setListGoodTypePo(goodTypeDao.getType(typeTwo.getId()));
			}
		}
		return oneGoodTypeList;
	}

}
